<template>
  <div>
    <van-nav-bar
      :title="item.reply_count ? item.reply_count + '条回复' : '暂无回复'"
      @click-left="$emit('close')"
    >
      <template #left>
        <van-icon name="cross" size="18" />
      </template>
    </van-nav-bar>
    <div class="mid-box">
      <comment-item :item="item" />
    <van-cell title="全部回复" />
    <comment-list :list="replyList" type="c" :ID="item.com_id + ''"  @onSuccess="onSuccess"/>
    </div>
    <div class="post-warp">
      <van-button @click="replyIsPopupShow=true" round>评论</van-button>
    </div>
    <van-popup v-model="replyIsPopupShow" position="bottom">
      <comment-post :target="item.com_id + ''" :artId="$route.params.artId"  @onSuccess="onSuccess" />
    </van-popup>
  </div>
</template>

<script>
import CommentItem from '@/components/CommentItem.vue'
import CommentList from './CommentList.vue'
import CommentPost from '@/components/CommentPost.vue'
export default {
  components: { CommentItem, CommentList, CommentPost },
  props: {
    item: {
      type: Object
    }
  },
  data () {
    return {
      replyList: [],
      replyIsPopupShow: false
    }
  },
  watch: {},
  created () {},

  methods: {
    onSuccess (e) {
      this.replyIsPopupShow = false
      this.replyList.unshift(e)
    }
  }
}
</script>

<style scoped lang="less">
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: hotpink;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
.mid-box{
  position: absolute;
  top: 92px;
  bottom: 100px;
  left: 0;
  right: 0;
  overflow-y: scroll;
}
</style>
